04. Solutions: FULL OUTER JOIN

Finding Matched and Unmatched Rows with FULL OUTER JOIN

SELECT *
  FROM accounts
 FULL JOIN sales_reps ON accounts.sales_rep_id = sales_reps.id

If unmatched rows existed (they don't for this query), you could isolate them by adding the following line to the end of the query:

WHERE accounts.sales_rep_id IS NULL OR sales_reps.id IS NULL

To elaborate on the rarity of FULL OUTER JOINS in practice, this Stack Overflow answer is helpful: When is a good situation to use a full outer join?

Workspace

This section contains either a workspace (it can be a Jupyter Notebook workspace or an online code editor work space, etc.) and it cannot be automatically downloaded to be generated here. Please access the classroom with your account and manually download the workspace to your local machine. Note that for some courses, Udacity upload the workspace files onto https://github.com/udacity, so you may be able to download them there.

Workspace Information:

  • Default file path:
  • Workspace type: sql-evaluator
  • Opened files (when workspace is loaded): n/a